package JavaHomework;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 姚东名
 * Date: 2024-06-07
 * Time: 10:12
 */
/**/
class Example {
    String str = new String("good");
    char[] ch = {'a', 'b', 'c'};

    public static void main(String args[]) {
        Example ex = new Example();
        ex.change(ex.str, ex.ch);
        System.out.print(ex.str + " and ");
        System.out.print(ex.ch);
    }

    public void change(String str, char ch[]) {
        //题解：形参的引用指向了 -> "test ok" ，但是实参的引用还是指向 -> "good",形参的改变不改变实参
        str = "test ok";
        //通过形参的引用修改了 字符数组里面的元素 -> ch[0] = 'g' 使得 'a' -> 'g'
        ch[0] = 'g';
    }
}


class SystemUtil {
    public static boolean isAdmin(String userId) {
        //return userId.toLowerCase() == "admin";//1.
        return userId.toLowerCase().equals("admin");//2.
    }

    public static void main(String[] args) {
        System.out.println(isAdmin("Admin"));//1.false  2.true
    }
}

class Solution {
    public int countSegments(String s) {
        //假如字符串长度为0时，就直接返回0就行了
        if(s.length() == 0) {
            return 0;
        }
        //计数：碰到是空字符串就直接跳过，不进行计数
        int count = 0;
        String[] ss = s.split(" ");
        /*for(String r : ss) {
            if(r.length() != 0) {
                count++;
            }
        }*/
        for(int i = 0; i < ss.length; i++) {
            if(ss[i].length() != 0) {
                count++;
            }
        }
        return count;
    }
}

public class Test {

}
